<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
        <p style="font-size: 25px;">计数器: {{ counter }}</p>
        <button v-on:click="counter++" style="font-size: 25px">点我</button>
    </div>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{
                counter:1
            },
            template:'<div class="app2"><h2>{{counter}}</h2></div>'
        });
        vm.$watch('counter',function (nval,oval) {
            alert('计数器值得变化: '+oval+' 变为 '+nval+'!');
        })
    </script>
</body>
</html>
